home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / uemacs-3.000 / uemacs-3 / uemacs-3.8 / estruct.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-23  |  17.8 KB  |  491 lines

  1. /*    ESTRUCT:    Structure and preprocesser defined for
  2.             MicroEMACS 3.8
  3.  
  4.             written by Dave G. Conroy
  5.             modified by Steve Wilhite, George Jones
  6.             greatly modified by Daniel Lawrence
  7. */
  8.  
  9. #ifdef    LATTICE
  10. #undef    LATTICE        /* don't use their definitions...use ours    */
  11. #endif
  12. #ifdef    MSDOS
  13. #undef    MSDOS
  14. #endif
  15. #ifdef    CPM
  16. #undef    CPM
  17. #endif
  18. #ifdef    AMIGA
  19. #undef    AMIGA
  20. #endif
  21.  
  22. /*    Version definition            */
  23.  
  24. #define    VERSION    "3.8b"
  25.  
  26. /*    Machine/OS definitions            */
  27.  
  28. #define AMIGA   0                       /* AmigaDOS            */
  29. #define ST520   0                       /* ST520, TOS                   */
  30. #define MSDOS   0                       /* MS-DOS                       */
  31. #define V7      0                       /* V7 UN*X or Coherent or BSD4.2*/
  32. #define    BSD    0            /* UNIX BSD 4.2    and ULTRIX    */
  33. #define    USG    1            /* UNIX system V        */
  34. #define VMS     0                       /* VAX/VMS                      */
  35. #define CPM     0                       /* CP/M-86                      */
  36. #define    FINDER    0            /* Macintosh OS            */
  37.  
  38. /*    Compiler definitions            */
  39. #define MWC86   0    /* marc williams compiler */
  40. #define    LATTICE    0    /* Lattice 2.14 thruough 3.0 compilers */
  41. #define    AZTEC    0    /* Aztec C 3.20e */
  42. #define    MSC    0    /* MicroSoft C compile version 3 */
  43. #define MEGAMAX 0    /* Megamax C compiler */
  44.  
  45. /*    Profiling options    */
  46. #define    APROF    0    /* turn Aztec C profiling on? */
  47. #define    NBUCK    100    /* number of buckets to profile */
  48. #define    RAMSIZE    0    /* dynamic RAM memory usage tracking */
  49. #define    RAMSHOW    1    /* auto dynamic RAM reporting */
  50.  
  51. /*   Special keyboard definitions            */
  52.  
  53. #define WANGPC    0        /* WangPC - mostly escape sequences     */
  54.  
  55. /*    Terminal Output definitions        */
  56.  
  57. #define ANSI    0            /* ansi escape sequences    */
  58. #define    HP150    0            /* HP150 screen driver        */
  59. #define    HP110    0            /* HP110 screen driver        */
  60. #define    VMSVT    0            /* various VMS terminal entries    */
  61. #define VT52    0                       /* VT52 terminal (Zenith).      */
  62. #define VT100   0                       /* Handle VT100 style keypad.   */
  63. #define LK201   0                       /* Handle LK201 style keypad.   */
  64. #define RAINBOW 0                       /* Use Rainbow fast video.      */
  65. #define NCURSES 0  /* whether we are linking with ncurses that defines `meta' */
  66. #define TERMCAP 1  /* Use TERMCAP                  */
  67. #define    IBMPC    0            /* IBM-PC CGA/MONO driver    */
  68. #define    EGA    0              /* EGA IBM-PC specific driver    */
  69. #define    DG10    0            /* Data General system/10    */
  70. #define    TIPC    0            /* TI Profesional PC driver    */
  71. #define    MAC    0            /* Macintosh            */
  72. #define    ATARI    0            /* Atari 520/1040ST screen    */
  73.  
  74. /*    Configuration options    */
  75.  
  76. #define CVMVAS  1    /* arguments to page forward/back in pages    */
  77. #define    NFWORD    1    /* forward word jumps to beginning of word    */
  78. #define    CLRMSG    0    /* space clears the message line with no insert    */
  79. #define    ACMODE    1    /* auto CMODE on .C and .H files        */
  80. #define    CFENCE    1    /* fench matching in CMODE            */
  81. #define    TYPEAH    1    /* type ahead causes update to be skipped    */
  82. #define DEBUGM    1    /* Global SPELL mode triggers macro debugging    */
  83. #define    VISMAC    0    /* update display during keyboard macros    */
  84. #define    CTRLZ    0    /* add a ^Z at end of files under MSDOS only    */
  85.  
  86. #define    REVSTA    1    /* Status line appears in reverse video        */
  87. #define    COLOR    1    /* color commands and windows            */
  88.  
  89. #define    FILOCK    0    /* file locking under unix BSD 4.2        */
  90. #define    ISRCH    1    /* Incremental searches like ITS EMACS        */
  91. #define    WORDPRO    1    /* Advanced word processing features        */
  92. #define    FLABEL    0    /* function key label code            */
  93. #define    APROP    1    /* Add code for Apropos command            */
  94. #define    CRYPT    1    /* file encryption enabled?            */
  95. #define MAGIC    1    /* include regular expression matching?        */
  96.  
  97. #define ASCII    1    /* always using ASCII char sequences for now    */
  98. #define EBCDIC    0    /* later IBM mainfraim versions will use EBCDIC    */
  99.  
  100. /*    System dependant library redefinitions, structures and includes    */
  101.  
  102. /*  Megamax C defines short to be 1 byte and int to be 2 bytes */
  103. #if    MEGAMAX & ST520
  104. #define SHORT int
  105. #else
  106. #define SHORT short
  107. #endif
  108.  
  109. #if    AZTEC
  110. #undef    fputc
  111. #undef    fgetc
  112. #define    fputc    aputc
  113. #define    fgetc    agetc
  114. #define    int86    sysint
  115. #define    intdos(a, b)    sysint(33, a, b)
  116. #define    inp    inportb
  117.  
  118. struct XREG {
  119.     int ax,bx,cx,dx,si,di;
  120. };
  121.  
  122. struct HREG {
  123.     char al,ah,bl,bh,cl,ch,dl,dh;
  124. };
  125.  
  126. union REGS {
  127.     struct XREG x;
  128.     struct HREG h;
  129. };
  130. #endif
  131.  
  132. #if    MSDOS & MWC86
  133. #include    <dos.h>
  134. #define    int86(a, b, c)    intcall(b, c, a)
  135. #define    inp    in
  136.  
  137. struct XREG {
  138.     int ax,bx,cx,dx,si,di,ds,es,flags;
  139. };
  140.  
  141. struct HREG {
  142.     char al,ah,bl,bh,cl,ch,dl,dh;
  143.     int ds,es,flags;
  144. };
  145.  
  146. union REGS {
  147.     struct XREG x;
  148.     struct HREG h;
  149. };
  150. #endif
  151.  
  152. #if    MSDOS & MSC
  153. #include    <dos.h>
  154. #define    movmem(a, b, c)        memcpy(b, a, c)
  155. #endif
  156.  
  157. #if    MSDOS & LATTICE
  158. #undef    CPM
  159. #undef    LATTICE
  160. #include    <dos.h>
  161. #undef    CPM
  162. #endif
  163.  
  164. #if    VMS
  165. #define    unlink(a)    delete(a)
  166. #endif
  167.  
  168. /*    define memory mapped flag    */
  169.  
  170. #define    MEMMAP    0
  171.  
  172. #if    IBMPC
  173. #undef    MEMMAP
  174. #define    MEMMAP    1
  175. #endif
  176.  
  177. #if    IBMMONO
  178. #undef    MEMMAP
  179. #define    MEMMAP    1
  180. #endif
  181.  
  182. #if    EGA
  183. #undef    MEMMAP
  184. #define    MEMMAP    1
  185. #endif
  186.  
  187. /*    internal constants    */
  188.  
  189. #define    NBINDS    256            /* max # of bound keys        */
  190. #define NFILEN  256                      /* # of bytes, file name        */
  191. #define NBUFN   16                      /* # of bytes, buffer name      */
  192. #define NLINE   4096                     /* # of bytes, line             */
  193. #define    NSTRING    128            /* # of bytes, string buffers    */
  194. #define NKBDM   256                     /* # of strokes, keyboard macro */
  195. #define NPAT    128                     /* # of bytes, pattern          */
  196. #define HUGE    1000                    /* Huge number                  */
  197. #define    NLOCKS    100            /* max # of file locks active    */
  198. #define    NCOLORS    16            /* number of supported colors    */
  199. #define    KBLOCK    250            /* sizeof kill buffer chunks    */
  200. #define    NBLOCK    16            /* line block chunk size    */
  201. #define    NVSIZE    10            /* max #chars in a var name    */
  202.  
  203. #if    0
  204. #define AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
  205. #define METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
  206. #define CTMECH  0x1C                    /* C-M- prefix, Control-\       */
  207. #define EXITCH  0x1D                    /* Exit level,  Control-]       */
  208. #define CTRLCH  0x1E                    /* C- prefix,   Control-^       */
  209. #define HELPCH  0x1F                    /* Help key,    Control-_       */
  210. #endif
  211.  
  212. #define CTRL    0x0100                  /* Control flag, or'ed in       */
  213. #define META    0x0200                  /* Meta flag, or'ed in          */
  214. #define CTLX    0x0400                  /* ^X flag, or'ed in            */
  215. #define    SPEC    0x0800            /* special key (function keys)    */
  216.  
  217. #define FALSE   0                       /* False, no, bad, etc.         */
  218. #define TRUE    1                       /* True, yes, good, etc.        */
  219. #define ABORT   2                       /* Death, ^G, abort, etc.       */
  220. #define    FAILED    3            /* not-quite fatal false return    */
  221. #define    RET    4            /* a return from buffer        */
  222. #define    GOLINE    5            /* exit flagging a GOTO        */
  223.  
  224. #define    STOP    0            /* keyboard macro not in use    */
  225. #define    PLAY    1            /*          playing    */
  226. #define    RECORD    2            /*          recording    */
  227.  
  228. #define    FORWARD    0            /* forward direction        */
  229. #define REVERSE    1            /* backwards direction        */
  230.  
  231. #define FIOSUC  0                       /* File I/O, success.           */
  232. #define FIOFNF  1                       /* File I/O, file not found.    */
  233. #define FIOEOF  2                       /* File I/O, end of file.       */
  234. #define FIOERR  3                       /* File I/O, error.             */
  235. #define    FIOLNG    4            /* line longer than allowed len    */
  236. #define    FIOFUN    5            /* File I/O, eod of file/bad line*/
  237.  
  238. #define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  239. #define CFKILL  0x0002                  /* Last command was a kill      */
  240.  
  241. #define    BELL    0x07            /* a bell character        */
  242. #define    TAB    0x09            /* a tab character        */
  243.  
  244. #if    V7 | USG | BSD
  245. #define    PATHCHR    ':'
  246. #else
  247. #define    PATHCHR    ';'
  248. #endif
  249.  
  250. #define    INTWIDTH    sizeof(int)/3 + 2
  251.  
  252. /*    Macro argument token types                    */
  253.  
  254. #define    TKNUL    0            /* end-of-string        */
  255. #define    TKARG    1            /* interactive argument        */
  256. #define    TKBUF    2            /* buffer argument        */
  257. #define    TKVAR    3            /* user variables        */
  258. #define    TKENV    4            /* environment variables    */
  259. #define    TKFUN    5            /* function....            */
  260. #define    TKDIR    6            /* directive            */
  261. #define    TKLBL    7            /* line label            */
  262. #define    TKLIT    8            /* numeric literal        */
  263. #define    TKSTR    9            /* quoted string literal    */
  264. #define    TKCMD    10            /* command name            */
  265.  
  266. /*    Internal defined functions                    */
  267.  
  268. /* DIFCASE represents the integer difference between upper
  269.    and lower case letters.  It is an xor-able value, which is
  270.    fortunate, since the relative positions of upper to lower
  271.    case letters is the opposite of ascii in ebcdic.
  272. */
  273.  
  274. #ifdef    islower
  275. #undef    islower
  276. #endif
  277.  
  278. #if    ASCII
  279.  
  280. #define    DIFCASE        0x20
  281. #define isletter(c)    (('a' <= c && 'z' >= c) || ('A' <= c && 'Z' >= c))
  282. #define islower(c)    (('a' <= c && 'z' >= c))
  283. #endif
  284.  
  285. #if    EBCDIC
  286.  
  287. #define    DIFCASE        0x40
  288. #define isletter(c)    (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c) || ('A' <= c && 'I' >= c) || ('J' <= c && 'R' >= c) || ('S' <= c && 'Z' >= c))
  289. #define islower(c)    (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c))
  290. #endif
  291.  
  292. /*    Dynamic RAM tracking and reporting redefinitions    */
  293.  
  294. #if    RAMSIZE
  295. #define    malloc    allocate
  296. #define    free    release
  297. #endif
  298.  
  299. /*
  300.  * There is a window structure allocated for every active display window. The
  301.  * windows are kept in a big list, in top to bottom screen order, with the
  302.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  303.  * The flag field contains some bits that are set by commands to guide
  304.  * redisplay; although this is a bit of a compromise in terms of decoupling,
  305.  * the full blown redisplay is just too expensive to run for every input
  306.  * character.
  307.  */
  308. typedef struct  WINDOW {
  309.         struct  WINDOW *w_wndp;         /* Next window                  */
  310.         struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
  311.         struct  LINE *w_linep;          /* Top line in the window       */
  312.         struct  LINE *w_dotp;           /* Line containing "."          */
  313.         short   w_doto;                 /* Byte offset for "."          */
  314.         struct  LINE *w_markp;          /* Line containing "mark"       */
  315.         short   w_marko;                /* Byte offset for "mark"       */
  316.         char    w_toprow;               /* Origin 0 top row of window   */
  317.         char    w_ntrows;               /* # of rows of text in window  */
  318.         char    w_force;                /* If NZ, forcing row.          */
  319.         char    w_flag;                 /* Flags.                       */
  320. #if    COLOR
  321.     char    w_fcolor;        /* current forground color    */
  322.     char    w_bcolor;        /* current background color    */
  323. #endif
  324. }       WINDOW;
  325.  
  326. #define WFFORCE 0x01                    /* Window needs forced reframe  */
  327. #define WFMOVE  0x02                    /* Movement from line to line   */
  328. #define WFEDIT  0x04                    /* Editing within a line        */
  329. #define WFHARD  0x08                    /* Better to a full display     */
  330. #define WFMODE  0x10                    /* Update mode line.            */
  331. #define    WFCOLR    0x20            /* Needs a color change        */
  332.  
  333. /*
  334.  * Text is kept in buffers. A buffer header, described below, exists for every
  335.  * buffer in the system. The buffers are kept in a big list, so that commands
  336.  * that search for a buffer by name can find the buffer header. There is a
  337.  * safe store for the dot and mark in the header, but this is only valid if
  338.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  339.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  340.  * the header line in "b_linep".
  341.  *     Buffers may be "Inactive" which means the files accosiated with them
  342.  * have not been read in yet. These get read in at "use buffer" time.
  343.  */
  344. typedef struct  BUFFER {
  345.         struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
  346.         struct  LINE *b_dotp;           /* Link to "." LINE structure   */
  347.         short   b_doto;                 /* Offset of "." in above LINE  */
  348.         struct  LINE *b_markp;          /* The same as the above two,   */
  349.         short   b_marko;                /* but for the "mark"           */
  350.         struct  LINE *b_linep;          /* Link to the header LINE      */
  351.     char    b_active;        /* window activated flag    */
  352.         char    b_nwnd;                 /* Count of windows on buffer   */
  353.         char    b_flag;                 /* Flags                        */
  354.     char    b_mode;            /* editor mode of this buffer    */
  355.         char    b_fname[NFILEN];        /* File name                    */
  356.         char    b_bname[NBUFN];         /* Buffer name                  */
  357. #if    CRYPT
  358.     char    b_key[NPAT];        /* current encrypted key    */
  359. #endif
  360. }       BUFFER;
  361.  
  362. #define BFINVS  0x01                    /* Internal invisable buffer    */
  363. #define BFCHG   0x02                    /* Changed since last write     */
  364.  
  365. /*    mode flags    */
  366. #define    NUMMODES    8        /* # of defined modes        */
  367.  
  368. #define    MDWRAP    0x0001            /* word wrap            */
  369. #define    MDCMOD    0x0002            /* C indentation and fence match*/
  370. #define    MDSPELL    0x0004            /* spell error parcing        */
  371. #define    MDEXACT    0x0008            /* Exact matching for searches    */
  372. #define    MDVIEW    0x0010            /* read-only buffer        */
  373. #define MDOVER    0x0020            /* overwrite mode        */
  374. #define MDMAGIC    0x0040            /* regular expresions in search */
  375. #define    MDCRYPT    0x0080            /* encrytion mode active    */
  376.  
  377. /*
  378.  * The starting position of a region, and the size of the region in
  379.  * characters, is kept in a region structure.  Used by the region commands.
  380.  */
  381. typedef struct  {
  382.         struct  LINE *r_linep;          /* Origin LINE address.         */
  383.         short   r_offset;               /* Origin LINE offset.          */
  384.         long    r_size;                 /* Length in characters.        */
  385. }       REGION;
  386.  
  387. /*
  388.  * All text is kept in circularly linked lists of "LINE" structures. These
  389.  * begin at the header line (which is the blank line beyond the end of the
  390.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  391.  * number of bytes in the line (the "used" size), the size of the text array,
  392.  * and the text. The end of line is not stored as a byte; it's implied. Future
  393.  * additions will include update hints, and a list of marks into the line.
  394.  */
  395. typedef struct  LINE {
  396.         struct  LINE *l_fp;             /* Link to the next line        */
  397.         struct  LINE *l_bp;             /* Link to the previous line    */
  398.         short   l_size;                 /* Allocated size               */
  399.         short   l_used;                 /* Used size                    */
  400.         char    l_text[1];              /* A bunch of characters.       */
  401. }       LINE;
  402.  
  403. #define lforw(lp)       ((lp)->l_fp)
  404. #define lback(lp)       ((lp)->l_bp)
  405. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  406. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  407. #define llength(lp)     ((lp)->l_used)
  408.  
  409. /*
  410.  * The editor communicates with the display using a high level interface. A
  411.  * "TERM" structure holds useful variables, and indirect pointers to routines
  412.  * that do useful operations. The low level get and put routines are here too.
  413.  * This lets a terminal, in addition to having non standard commands, have
  414.  * funny get and put character code too. The calls might get changed to
  415.  * "termp->t_field" style in the future, to make it possible to run more than
  416.  * one terminal type.
  417.  */
  418. typedef struct  {
  419.     short    t_mrow;            /* max number of rows allowable */
  420.         short   t_nrow;                 /* current number of rows used  */
  421.         short   t_mcol;                 /* max Number of columns.       */
  422.         short   t_ncol;                 /* current Number of columns.   */
  423.     short    t_margin;        /* min margin for extended lines*/
  424.     short    t_scrsiz;        /* size of scroll region "    */
  425.     int    t_pause;        /* # times thru update to pause */
  426.         int     (*t_open)();            /* Open terminal at the start.  */
  427.         int     (*t_close)();           /* Close terminal at end.       */
  428.     int    (*t_kopen)();        /* Open keyboard        */
  429.     int    (*t_kclose)();        /* close keyboard        */
  430.         int     (*t_getchar)();         /* Get character from keyboard. */
  431.         int     (*t_putchar)();         /* Put character to display.    */
  432.         int     (*t_flush)();           /* Flush output buffers.        */
  433.         int     (*t_move)();            /* Move the cursor, origin 0.   */
  434.         int     (*t_eeol)();            /* Erase to end of line.        */
  435.         int     (*t_eeop)();            /* Erase to end of page.        */
  436.         int     (*t_beep)();            /* Beep.                        */
  437.     int    (*t_rev)();        /* set reverse video state    */
  438.     int    (*t_rez)();        /* change screen resolution    */
  439. #if    COLOR
  440.     int    (*t_setfor)();        /* set forground color        */
  441.     int    (*t_setback)();        /* set background color        */
  442. #endif
  443. }       TERM;
  444.  
  445. /*    TEMPORARY macros for terminal I/O  (to be placed in a machine
  446.                         dependant place later)    */
  447.  
  448. #define    TTopen        (*term.t_open)
  449. #define    TTclose        (*term.t_close)
  450. #define    TTkopen        (*term.t_kopen)
  451. #define    TTkclose    (*term.t_kclose)
  452. #define    TTgetc        (*term.t_getchar)
  453. #define    TTputc        (*term.t_putchar)
  454. #define    TTflush        (*term.t_flush)
  455. #define    TTmove        (*term.t_move)
  456. #define    TTeeol        (*term.t_eeol)
  457. #define    TTeeop        (*term.t_eeop)
  458. #define    TTbeep        (*term.t_beep)
  459. #define    TTrev        (*term.t_rev)
  460. #define    TTrez        (*term.t_rez)
  461. #if    COLOR
  462. #define    TTforg        (*term.t_setfor)
  463. #define    TTbacg        (*term.t_setback)
  464. #endif
  465.  
  466. /*    structure for the table of initial key bindings        */
  467.  
  468. typedef struct  {
  469.         short   k_code;                 /* Key code                     */
  470.         int     (*k_fp)();              /* Routine to handle it         */
  471. }       KEYTAB;
  472.  
  473. /*    structure for the name binding table        */
  474.  
  475. typedef struct {
  476.     char *n_name;        /* name of function key */
  477.     int (*n_func)();    /* function name is bound to */
  478. }    NBIND;
  479.  
  480. /*    The editor holds deleted text chunks in the KILL buffer. The
  481.     kill buffer is logically a stream of ascii characters, however
  482.     due to its unpredicatable size, it gets implemented as a linked
  483.     list of chunks. (The d_ prefix is for "deleted" text, as k_
  484.     was taken up by the keycode structure)            */
  485.  
  486. typedef    struct KILL {
  487.     struct KILL *d_next;    /* link to next chunk, NULL if last */
  488.     char d_chunk[KBLOCK];    /* deleted text */
  489. } KILL;
  490.  
  491.